local hebing = fk.CreateSkill{
  name = "lz__hebing",
  tags = { Skill.Compulsory }
}

Fk:loadTranslationTable{
  ["lz__hebing"] = "赫炳",
  [":lz__hebing"] = "锁定技，回合开始时，你执行以下一项：1.对一名未以此法选择过的角色造成1点伤害；2.减1点体力上限并摸两张牌；3.失去此技能并获得“连破”。",
  ["#hebing-choose"] = "请选择一名未被赫炳选择过的角色",
  ["lz__hebing1"] = "对一名未以此法选择过的角色造成1点伤害",
  ["lz__hebing2"] = "减1点体力上限并摸两张牌",
  ["lz__hebing3"] = "失去此技能并获得“连破”",
  ["@[player]hebing"] = "赫炳",
  -- 语音台词
  ["$hebing1"] = "赫然而怒，炳如日星！",
  ["$hebing2"] = "破敌摧坚，势不可挡！",
}

hebing:addEffect(fk.TurnStart, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(hebing.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choices = {"lz__hebing1", "lz__hebing2", "lz__hebing3"}
    local all_choices = table.simpleClone(choices)
    local availableTargets = table.filter(room.alive_players, function(p)
      return not table.contains(player:getTableMark("@[player]hebing"), p.id) end)
    if #availableTargets == 0 then table.remove(choices, 1) end
    local choice = player.room:askToChoice(player, {
      choices = choices,
      skill_name = hebing.name,
      all_choices = all_choices,
    })
    if choice == "lz__hebing1" then
      local result = room:askToChoosePlayers(player, {
        targets = availableTargets,
        min_num = 1,
        max_num = 1,
        prompt = "#hebing-choose",
        skill_name = hebing.name,
       })
       if #result > 0 then
          room:addTableMarkIfNeed(player, "@[player]hebing", result[1].id)
          room:damage({
            from = player,
            to = result[1],
            damage = 1,
            skillName = hebing.name,
          })
       end
    elseif choice == "lz__hebing2" then
        room:changeMaxHp(player, -1)
        player:drawCards(2, hebing.name)
    elseif choice == "lz__hebing3" then
       room:handleAddLoseSkills(player, "-lz__hebing")
       room:handleAddLoseSkills(player, "lz__lianpo")
    end
  end,
})

return hebing